package edu.uow.devdocs
/**
 * The DevelopmentTask entity.
 *
 * @author    
 *
 *
 */
class DevelopmentTask {
    static mapping = {
         table 'DEVELOPMENT_TASK'
         // version is set to false, because this isn't available by default for legacy databases
         version false
         id column:'DEVELOPMENT_TASK_ID'
		 id generator: 'sequence', params:[sequence:'DEVELOPMENT_TASK_SEQ']
         project column:'SUB_SYSTEM_ID'
         status column:'STATUS_ID'
         issue column:'ISSUE_ID'
         deployment column:'DEPLOYMENT_ID'
		 sort dateCreated:'DESC'
    }
    Date dateCreated = new Date()
    java.math.BigDecimal priority = 3
    String reference
    Date dateRequired
    String task
    Date lastUpdated
    // Relation
    Project project
    // Relation
    DevelopmentTaskStatus status
    // Relation
    Issue issue
    // Relation
    Deployment deployment
	
	List developmentChecklists = new ArrayList()
	
	static searchable = {
		id name:'task'}
	
	static hasMany = [developmentChecklists: DevelopmentChecklist]

    static constraints = {
        dateCreated(nullable: true)
        priority(nullable: false, range: 1..5)
        reference(nullable: true,size: 0..20)
        dateRequired(nullable: true)
        task(size: 0..255)
        lastUpdated(nullable: true)
		deployment(nullable:true)
    }
    String toString() {
        return "${task?.length() > 50 ? task.substring(0,50) + '....' : task}" 
    }
}
